{extend name="base/main" /}
{block name="body"}
<link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
<script src="/static/layui/layui.js" charset="utf-8"></script>
<div class="ibox-content">
    <form id="f" action="{:url('Marketing/activity_add')}" class="form-horizontal m-t" method="post" >
        <div class="layui-inline">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-inline">
                <input type="tel" name="a_name" lay-verify="required|phone" autocomplete="off" class="layui-input" placeholder="请输入要查询的数据">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">报名时间</label>
                <div class="layui-inline" id="test6">
                    <div class="layui-input-inline">
                        <input type="text" name="h_s_time" autocomplete="off" id="test-startDate-1" class="layui-input" placeholder="开始日期">
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline">
                        <input type="text" name="h_f_time" autocomplete="off" id="test-endDate-1" class="layui-input" placeholder="结束日期">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">活动时间</label>
                    <div class="layui-inline" id="test5">
                        <div class="layui-input-inline">
                            <input type="text" name="s_time" autocomplete="off" id="test-startDate-2" class="layui-input" placeholder="开始日期">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" name="f_time" autocomplete="off" id="test-endDate-2" class="layui-input" placeholder="结束日期">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">人数</label>
            <div class="layui-input-inline">
                <input type="tel" name="a_number" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-upload">
            <label class="col-sm-1 control-label">图片-：</label>
            <div class="col-sm-4">
                <button type="button" class="layui-btn" id="test1">上传封面</button>
                <div class="layui-upload-list">
                    <img class="layui-upload-img" id="demo1" name="img" width="95px" height="80px">
                    <p id="demoText"></p>
                    <input type="hidden" name="img" id="img">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="col-sm-1 control-label">地址：</label>
            <div class="layui-input-inline">
                <input type="tel" name="site" lay-verify="required|phone" autocomplete="off" class="layui-input" placeholder="详情地址">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-1 control-label">简介：</label>
            <div class="col-sm-4">
                <textarea name="rule" id="editor_j"></textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">内容：</label>
            <div class="col-sm-4">
                <textarea name="details" id="editor_n"></textarea>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="number" name="sort" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">限购</label>
            <div class="layui-input-inline">
                <input type="tel" name="l_purchase" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">活动状态</label>
            <div class="layui-input-block">
                <input type="radio" name="state" value="显示" title="显示" checked="">
                <input type="radio" name="state" value="不显示" title="不显示">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否填写资料</label>
            <div class="layui-input-block">
                <input type="radio" name="data" value="填写" title="填写" checked="">
                <input type="radio" name="data" value="不填写" title="不填写">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">付费方式</label>
            <div class="layui-input-block">
                <input type="radio" name="payment" value="付费" title="付费" checked="">
                <input type="radio" name="payment" value="不付费" title="不付费">
            </div>
        </div>

        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <button class="btn btn-primary" type="submit">提交</button>
                <button class="btn btn-default historygo" type="button">返回</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use('laydate', function(){

        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#test6'
            //设置开始日期、日期日期的 input 选择器
            //数组格式为 2.6.6 开始新增，之前版本直接配置 true 或任意分割字符即可
            ,range: ['#test-startDate-1', '#test-endDate-1']
        });
        laydate.render({
            elem: '#test5'
            //设置开始日期、日期日期的 input 选择器
            //数组格式为 2.6.6 开始新增，之前版本直接配置 true 或任意分割字符即可
            ,range: ['#test-startDate-2', '#test-endDate-2']
        });
    });
</script>

<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
    var ue1 = UE.getEditor('editor_j',{});
    var ue2 = UE.getEditor('editor_n',{});
    layui.use(['upload', 'element', 'layer','form'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;
        //常规使用 - 普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: "{:url('Marketing/picture')}" //改成自己的上传接口
            ,before: function(obj){
                //预读本地文件示例
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                if(res.code == 0){
                    $('#img').val(res.data);
                    return layer.msg('上传成功');
                }
                //上传成功的一些操作
                //……
                $('#demoText').html(''); //置空上传失败的状态
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    });
</script>
{/block}